﻿//AcademicPlanner - course registration planning web app.
//Copyright (C) 2009  Boubacar Diallo

//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or (at your option) any later version.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.


using System;
using System.Collections.Generic;
using System.Linq;
using AcademicPlanner.Domain.Models.Collections;

namespace AcademicPlanner.Domain.Models
{
	/// <summary>
	/// MainModel represents the top level model of the AcademicPlanner 
	/// application. It holds references to models that do not aggreagately
	/// belong to any model and serves as an accessor to all system wide
	/// models.
	/// </summary>
	/// <since>1.0</since>
    public class MainModel
    {
		PersonCollection allPeople;

		AccountCollection allAccounts;

		PlannerCollection allPlanners;

		AcademicPlanCollection allPlans;

		ProgramCollection allPrograms;

		CourseCollection allCourses;

		AcademicScheduleCollection allSchedules;


		/// <summary>
		/// Gets the collection of all <c>Person</c>s in the system.
		/// </summary>
		/// <since>1.0</since>
		public PersonCollection AllPeople 
		{
			get
			{
				if (allPeople == null)
					allPeople = new PersonCollection();
				return allPeople; 
			} 
		}

		/// <summary>
		/// Gets the collection of all <c>Account</c>s in the system.
		/// </summary>
		/// <since>1.0</since>
		public AccountCollection AllAccounts 
		{
			get
			{
				if (allAccounts == null)
					allAccounts = new AccountCollection();
				return allAccounts; 
			} 
		}

		/// <summary>
		/// Gets the collection of all <c>Planner</c>s in the system.
		/// </summary>
		/// <since>1.0</since>
		public PlannerCollection AllPlanners 
		{
			get
			{
				if (allPlanners == null)
					allPlanners = new PlannerCollection();
				return allPlanners; 
			} 
		}

		/// <summary>
		/// Gets the collection of all <c>AcademicPlan</c>s in the system.
		/// </summary>
		/// <since>1.0</since>
		public AcademicPlanCollection AllPlans 
		{
			get
			{ 
				if (allPlans == null)
					allPlans = new AcademicPlanCollection();
				return allPlans; 
			} 
		}

		/// <summary>
		/// Gets the collection of all <c>Program</c>s in the system.
		/// </summary>
		/// <since>1.0</since>
		public ProgramCollection AllPrograms 
		{
			get
			{ 
				if (allPrograms == null)
					allPrograms = new ProgramCollection();
				return allPrograms; 
			} 
		}

		/// <summary>
		/// Gets the collection of all <c>Course</c>s in the system.
		/// </summary>
		/// <since>1.0</since>
		public CourseCollection AllCourses 
		{
			get
			{
				if (allCourses == null)
					allCourses = new CourseCollection();
				return allCourses; 
			} 
		}

		/// <summary>
		/// Gets the collection of all <c>AcademicSchedule</c>s in the system.
		/// </summary>
		/// <since>1.0</since>
		public AcademicScheduleCollection AllSchedules
		{
			get
			{
				if (allSchedules == null)
					allSchedules = new AcademicScheduleCollection();
				return allSchedules;
			}
		}


		MainModel() {}

		class InstanceHolder 
		{
			internal static MainModel INSTANCE = new MainModel(); 
		}


		/// <summary>
		/// Gets the single MainModel instance.
		/// </summary>
		/// <returns>The single MainModel instance.</returns>
		/// <since>1.0</since>
		internal static MainModel GetInstance()
		{ 
			return InstanceHolder.INSTANCE; 
		}
    }
}
